package com.nvwa.mvp.abase.logfilter;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
import lombok.Setter;

@Setter
public class MyLogFilter extends Filter<ILoggingEvent> {
    private String keyword;

    @Override
    public FilterReply decide(ILoggingEvent iLoggingEvent) {
        if (!this.isStarted()) {
            return FilterReply.NEUTRAL;
        }
        if (iLoggingEvent.getMessage().contains(this.keyword)) {
            return FilterReply.ACCEPT;
        }
        return FilterReply.DENY;
    }
}
